/*
 * Copyright (c) 2017年11月09日  by XuanWu Wireless Technology Co., Ltd 
 *             All rights reserved  
 */
package com.zml.tenth.example;

/**
 * @author <a href="mailto:zhaominglin@wxchina.com">minglin.Zhao</a>
 * @Description
 * @Date 2017/11/9
 * @Version 1.0.0
 */
public class GumballMachine {
    final static int SOLD_OUT = 0;
    final static int NO_QUARTER = 1;
    final static int HAS_QUARTER = 2;
    final static int SOLD = 3;

    int state = SOLD_OUT;
    int count = 0;

    public GumballMachine(int count) {
        this.count = count;
        if (count > 0) {
            state = NO_QUARTER;
        }
    }
    public void insertQuarter(){
        if(state == HAS_QUARTER){
            System.out.println("You can't insert another quarter");
        }else if (state == NO_QUARTER){
            state = HAS_QUARTER;
            System.out.println("You inserted a quarter");
        }else if (state == SOLD_OUT){
            System.out.println("You can't insert a quarter ,the machine is sold out");
        }else if (state == SOLD){
            System.out.println("Please wait, we're already giving you a gumball");
        }
    }

    public void ejectQuarter(){
        //退回25分钱
    }
    public void turnGrank(){
        //转动曲柄
    }
    public void dispense(){
        //发放糖果
    }
}
